const path = require('path');
const _ = require('lodash');
const getRelativePath = require('./get-relative-path');

function getRule(filePath, ruleObj) {
    let currentPath = path.dirname(filePath);

    while (currentPath !== '/') {
        // const pathname = path.basename(currentPath);
        const rule = ruleObj[currentPath];
        if (rule) {
            return rule;
        }
        currentPath = path.dirname(currentPath);
    }

    return null;
}

module.exports = getRule;